$(function(){
	$('#add-address').click(function(){
		window.location.href="add_address2.html"
	})
})

//获取用户地址
$(function(){
	$.ajax({
		url:'/user/getAddress.json',
		dataType:'json',
		type:'post',
		data:{
			token:getItem('token'),
		},
		success:function(data){
			if(data.code==0){
				if(data.msg=="请添加地址"){
					$('<div class="kong"><img src="../img/kong.png" alt="暂无数据"></div>').appendTo($('.mui-content'));
				}else{
					mui.toast(data.msg);
				}
			}
			if(data.code==-1){
				window.location.href="login.html";
			}
			if(data.code==1){
				$('.mui-content').empty();
				var data =data.datas;
				if(data.address==undefined||data.address==""||data.address==null){
					$('<div>你还没有添加收获地址</div>').appendTo($('.mui-content'));
					return;
				}
					$('<a href="add_address2.html"><div class="address-box"><div class="if-default">'+
						'<img src="../img/selected.png"/></div>'+
						'<div class="address"><span>'+data.address.userName+'</span>'+
						'<span></span>'+
						'<span>'+data.address.province+data.address.city+data.address.county+'</span>'+
						'</div><div class="edit">'+
						'<img src="../img/edit.png" alt="编辑" />'+
						'</div></div></a>').appendTo($('.mui-content'));
			}
		}
	})
})
